<?php 
require_once('dao/GrilleTarifMobileDao.php');
if ($_SESSION['niveauAuth']=='1' or $_SESSION['niveauAuth']=='2' or $_SESSION['niveauAuth']=='4'or $_SESSION['niveauAuth']=='5'or $_SESSION['niveauAuth']=='6'or $_SESSION['niveauAuth']=='7' or $_SESSION['niveauAuth']=='8') {
/**
 * Controleur pour la creation de tarif
 */
	
	
//création d'une nouveaux tarif
if (isset($_POST['creation']))
{
$requete = $bdd->prepare("INSERT INTO `mobile_tarification` (`id`,`prix_ha`,`code_FT`, `libelle`,`type`, `prix_1`, `prix_2`, `prix_3`, `prix_4`,`prix_5`) VALUES ('','".$_POST['prix_ha']."','".$_POST['code_FT']."', '".$_POST['libelle']."', '".$_POST['type']."','".$_POST['prix_1']."','".$_POST['prix_2']."','".$_POST['prix_3']."' ,'".$_POST['prix_4']."','".$_POST['prix_5']."') ");
			
			$requete->execute() or exit(print_r($bdd->errorInfo()));

	
	// Redirection vers la page 
	if ($_POST['action'] == "creation"){
			// Pas de changement de page
			$success=true;
	} else if ($_POST['action'] == "grille-tarif-mobile-creation"){
			header("Location:grille-tarif-mobile-creation?success=true");
	} else if ($_POST['action'] == "grille-tarif-mobile"){
		header("Location:grille-tarif-mobile?success=true");
	}
}

//$twig = new Twig_Environment($loader, array(
 //   'debug' => true,
//)); 
//$twig->addExtension(new Twig_Extension_Debug());
// a afficher dans le html: {{ debug() }}

echo $twig->render('grille-tarif-mobile-creation.html');

}
else {
	redirect("home-admin");
}
